home *** CD-ROM | disk | FTP | other *** search
/ Aminet 25 / Aminet 25 (1998)(GTI - Schatztruhe)[!][Jun 1998].iso / Aminet / util / libs / ixemul_sdk.lha / man / cat3 / bitstring.0 < prev    next >
Text File  |  1998-03-21  |  4KB  |  96 lines

  1.  
  2. BITSTRING(3)               UNIX Programmer's Manual               BITSTRING(3)
  3.  
  4. NNAAMMEE
  5.      bbiitt__aalllloocc, bbiitt__cclleeaarr, bbiitt__ddeeccll, bbiitt__ffffss, bbiitt__nncclleeaarr, bbiitt__nnsseett,, bbiitt__sseett,
  6.      bbiittssttrr__ssiizzee, bbiitt__tteesstt - bit-string manipulation macros
  7.  
  8. SSYYNNOOPPSSIISS
  9.      ##iinncclluuddee <<bbiittssttrriinngg..hh>>
  10.  
  11.      _b_i_t_s_t_r___t _*
  12.      bbiitt__aalllloocc(_i_n_t _n_b_i_t_s)
  13.  
  14.      bbiitt__ddeeccll(_b_i_t___s_t_r _n_a_m_e, _i_n_t _n_b_i_t_s)
  15.  
  16.      bbiitt__cclleeaarr(_b_i_t___s_t_r _n_a_m_e, _i_n_t _b_i_t)
  17.  
  18.      bbiitt__ffffcc(_b_i_t___s_t_r _n_a_m_e, _i_n_t _n_b_i_t_s, _i_n_t _*_v_a_l_u_e)
  19.  
  20.      bbiitt__ffffss(_b_i_t___s_t_r _n_a_m_e, _i_n_t _n_b_i_t_s, _i_n_t _*_v_a_l_u_e)
  21.  
  22.      bbiitt__nncclleeaarr(_b_i_t___s_t_r _n_a_m_e, _i_n_t _s_t_a_r_t, _i_n_t _s_t_o_p)
  23.  
  24.      bbiitt__nnsseett(_b_i_t___s_t_r _n_a_m_e, _i_n_t _s_t_a_r_t, _i_n_t _s_t_o_p)
  25.  
  26.      bbiitt__sseett(_b_i_t___s_t_r _n_a_m_e, _i_n_t _b_i_t)
  27.  
  28.      bbiittssttrr__ssiizzee(_i_n_t _n_b_i_t_s)
  29.  
  30.      bbiitt__tteesstt(_b_i_t___s_t_r _n_a_m_e, _i_n_t _b_i_t)
  31.  
  32. DDEESSCCRRIIPPTTIIOONN
  33.      These macros operate on strings of bits.
  34.  
  35.      The macro bbiitt__aalllloocc() returns a pointer of type ``_b_i_t_s_t_r___t _*'' to suffi-
  36.      cient space to store _n_b_i_t_s bits, or NULL if no space is available.
  37.  
  38.      The macro bbiitt__ddeeccll() allocates sufficient space to store _n_b_i_t_s bits on
  39.      the stack.
  40.  
  41.      The macro bbiittssttrr__ssiizzee() returns the number of elements of type _b_i_t_s_t_r___t
  42.      necessary to store _n_b_i_t_s bits.  This is useful for copying bit strings.
  43.  
  44.      The macros bbiitt__cclleeaarr() and bbiitt__sseett() clear or set the zero-based numbered
  45.      bit _b_i_t, in the bit string _n_a_m_e.
  46.  
  47.      The bbiitt__nnsseett() and bbiitt__nncclleeaarr() macros set or clear the zero-based num-
  48.      bered bits from _s_t_a_r_t to _s_t_o_p in the bit string _n_a_m_e.
  49.  
  50.      The bbiitt__tteesstt() macro evaluates to non-zero if the zero-based numbered bit
  51.      _b_i_t of bit string _n_a_m_e is set, and zero otherwise.
  52.  
  53.      The bbiitt__ffffss() macro stores in the location referenced by _v_a_l_u_e the zero-
  54.      based number of the first bit set in the array of _n_b_i_t_s bits referenced
  55.      by _n_a_m_e. If no bits are set, the location referenced by _v_a_l_u_e is set to
  56.      -1.
  57.  
  58.      The macro bbiitt__ffffcc() stores in the location referenced by _v_a_l_u_e the zero-
  59.      based number of the first bit not set in the array of _n_b_i_t_s bits refer-
  60.      enced by _n_a_m_e. If all bits are set, the location referenced by _v_a_l_u_e is
  61.      set to -1.
  62.  
  63.      The arguments to these macros are evaluated only once and may safely have
  64.      side effects.
  65.  
  66. EEXXAAMMPPLLEE
  67.            #include <limits.h>
  68.            #include <bitstring.h>
  69.  
  70.            #define LPR_BUSY_BIT            0
  71.            #define LPR_FORMAT_BIT          1
  72.            #define LPR_DOWNLOAD_BIT        2
  73.            #define LPR_AVAILABLE_BIT       9
  74.            #define LPR_MAX_BITS            10
  75.  
  76.            make_lpr_available()
  77.            {
  78.                    bitstr_t bit_decl(bitlist, LPR_MAX_BITS);
  79.                    ...
  80.                    bit_nclear(bitlist, 0, LPR_MAX_BITS - 1);
  81.                    ...
  82.                    if (!bit_test(bitlist, LPR_BUSY_BIT)) {
  83.                            bit_clear(bitlist, LPR_FORMAT_BIT);
  84.                            bit_clear(bitlist, LPR_DOWNLOAD_BIT);
  85.                            bit_set(bitlist, LPR_AVAILABLE_BIT);
  86.                    }
  87.            }
  88.  
  89. SSEEEE AALLSSOO
  90.      malloc(3)
  91.  
  92. HHIISSTTOORRYY
  93.      The bbiittssttrriinngg functions first appeared in 4.4BSD.
  94.  
  95. 4th Berkeley Distribution        July 19, 1993                               2
  96.